package com.qidian.mes.defect.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidian.mes.defect.mapper.ShipmentMapper;
import com.qidian.mes.defect.service.ShipmentService;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.Shipment;
import com.qidianit.mes.pojo.TestProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author 泽华
 * @Description
 * @Time 2024-10-24 0:33
 */
@Service
public class ShipmentServiceImpl implements ShipmentService {
    @Autowired
    private ShipmentMapper shipmentMapper;


    @Override
    public MESResult list(Shipment shipment, int page, int limit) {
        // 开启分页  参数1： 页码  参数2： 每页大小
        PageHelper.startPage(page,limit);
        // 查询全部
        List<Shipment> shipments = shipmentMapper.selectList(shipment);
        PageInfo<Shipment> pageInfo = new PageInfo<>(shipments);
        // 将pageInfo对象设置到MESResult中
        return MESResult.success(pageInfo);

    }

    @Override
    public MESResult save(Shipment shipment) {
        return shipmentMapper.insert(shipment) == 1?MESResult.success():MESResult.error();

    }

    @Override
    public MESResult update(Shipment shipment) {
        return MESResult.success(200,"ok",shipmentMapper.update(shipment));

    }

    @Override
    public MESResult selectById(Long shipmentId) {
        return MESResult.success(shipmentMapper.selectById(shipmentId));
    }
}
